﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data.Mapping {
	public partial class TopicProductMap : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<TopicProduct> {
		public TopicProductMap() {
			ToTable("mc_TopicProduct", "dbo");

			HasKey(t => t.Id);
			Property(t => t.Id)
				.HasColumnName("Id")
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
				.IsRequired();
			Property(t => t.GroupId)
				.HasColumnName("GroupId")
				.IsRequired();
			Property(t => t.ProductId)
				.HasColumnName("ProductId")
				.IsRequired();
			Property(t => t.Sort)
				.HasColumnName("Sort")
				.IsRequired();

			// Relationships
			HasRequired(t => t.TopicGroup)
				.WithMany(t => t.TopicProducts)
				.HasForeignKey(d => d.GroupId)
				.WillCascadeOnDelete(false);
			HasRequired(t => t.Product)
				.WithMany()
				.HasForeignKey(d => d.ProductId)
				.WillCascadeOnDelete(false);
		}
	}
}
